import pandas as pd
import matplotlib.pyplot as plt

FILEPATH = "./effectOfKWayMerge.csv"

df = pd.read_csv(FILEPATH)

df = df.groupby("K")["Time"].mean().reset_index()

# 修改x轴从2开始
plt.plot(df["K"], df["Time"])
plt.xlabel("K")
plt.ylabel("Time")
plt.xlim(2, df["K"].max())
plt.show()

# # 读取数据
# phase2_data = pd.read_csv('./Phase2Performance.csv')
# phase3_data = pd.read_csv('./Phase3Performance.csv')
# phase4_data = pd.read_csv('./Phase4Performance.csv')
#
# # 绘制 runGenerationTime
# plt.figure(figsize=(8, 6))
# plt.plot(range(1, 11), phase2_data['runGenerationTime'], label='Phase 2', marker='o')
# plt.plot(range(1, 11), phase3_data['runGenerationTime'], label='Phase 3', marker='s')
# plt.plot(range(1, 11), phase4_data['runGenerationTime'], label='Phase 4', marker='^')
# plt.title('Run Generation Time')
# plt.xlabel('Run Number')
# plt.ylabel('Time (seconds)')
# plt.legend()
# plt.grid(True)
# plt.show()
#
# # 绘制 mergeTime
# plt.figure(figsize=(8, 6))
# plt.plot(range(1, 11), phase2_data['mergeTime'], label='Phase 2', marker='o')
# plt.plot(range(1, 11), phase3_data['mergeTime'], label='Phase 3', marker='s')
# plt.plot(range(1, 11), phase4_data['mergeTime'], label='Phase 4', marker='^')
# plt.title('Merge Time')
# plt.xlabel('Run Number')
# plt.ylabel('Time (seconds)')
# plt.legend()
# plt.grid(True)
# plt.show()
#
# # 绘制 runGenerationMem
# plt.figure(figsize=(8, 6))
# plt.plot(range(1, 11), phase2_data['runGenerationMem'], label='Phase 2', marker='o')
# plt.plot(range(1, 11), phase3_data['runGenerationMem'], label='Phase 3', marker='s')
# plt.plot(range(1, 11), phase4_data['runGenerationMem'], label='Phase 4', marker='^')
# plt.title('Run Generation Memory')
# plt.xlabel('Run Number')
# plt.ylabel('Memory (MB)')
# plt.legend()
# plt.grid(True)
# plt.show()
#
# # 绘制 mergeMem
# plt.figure(figsize=(8, 6))
# plt.plot(range(1, 11), phase2_data['mergeMem'], label='Phase 2', marker='o')
# plt.plot(range(1, 11), phase3_data['mergeMem'], label='Phase 3', marker='s')
# plt.plot(range(1, 11), phase4_data['mergeMem'], label='Phase 4', marker='^')
# plt.title('Merge Memory')
# plt.xlabel('Run Number')
# plt.ylabel('Memory (MB)')
# plt.legend()
# plt.grid(True)
# plt.show()